/**
    package: learn-go
    filename: sort
    author: diogo
    time: 2021/7/19 11:38
**/
package main

import (
	"fmt"
	"sort"
)

func main() {

	temp := []string{"xxx", "aaa", "bbb", "ccc", "ddd"}

	fmt.Println(temp)

	Index, isFond := IsExist(temp, "xc")
	fmt.Println(isFond)
	fmt.Println(Index)
}

func IsExist(s []string, t string) (int, bool) {
	iIndex := sort.SearchStrings(s, t)
	bExist := iIndex != len(s) && s[iIndex] == t

	return iIndex, bExist
}
